// 返回长度为k且平均值大于等于value的子数组数目
// 思路，固定窗口
// 定义两个指针，分别指向窗口的左右两端

function numOfSubarrays(arr, k, value) {
    let left = 0
    let right= 0
    let windowSum = 0
    let res = 0
    while (right < arr.length) {
        windowSum += arr[right]
        if (right - left + 1 >= k) {
            if (windowSum >= k * value) {
                res += 1
            }
            windowSum -= arr[left]
            left++
        }
        right++
    }
    return res
}

let arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3]
console.log(numOfSubarrays(arr, 3, 5));